package com.kws.merchant.mapper;

import com.kws.merchant.domain.ContractSignature;
import com.kws.merchant.domain.OperationPolling;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * 运维-巡检管理(OperationPolling)表数据库访问层
 *
 * @author yxy
 * @since 2024-10-28 11:32:39
 */

public interface OperationPollingMapper extends BaseMapper<OperationPolling> {


    @Select("select count(*) from tb_operation_polling o left join tb_item i on o.item_id=i.id where ${sql};")
    int countToTal(@Param("sql") String sql);

    @Select("select o.*,i.item_name,u.nick_name as polling_user_name,u1.nick_name as next_polling_user_name from tb_operation_polling o left join tb_item i on o.item_id=i.id left join sys_user u on o.polling_user_id=u.user_id left join sys_user u1 on o.next_polling_user=u1.user_id  where ${sql} limit ${sizeNum},${totalPage}; ")
    List<OperationPolling> getRecords(@Param("sql") String sql,@Param("sizeNum") int sizeNum,@Param("totalPage") Integer totalPage);

    @Select("select count(*) from tb_operation_polling where merchant_id=${companyId} ${sql};")
    Double countWorkTypeBySql(@Param("companyId") Long companyId,@Param("sql") String sql);

    @Select("select o.*,i.item_name,u.nick_name as polling_user_name,u1.nick_name as next_polling_user_name from tb_operation_polling o left join tb_item i on o.item_id=i.id left join sys_user u on o.polling_user_id=u.user_id left join sys_user u1 on o.next_polling_user=u1.user_id where o.id=${id}")
    OperationPolling detailById(@Param("id") Long id);
}
